package com.LeeG.work.Sort.cmp;

import com.LeeG.work.Sort.Sort;

import java.util.Arrays;

/**
 * @author LeeG
 * @Description: 选择排序
 * @date 2021/1/17 16:53
 */
public class SelectionSort extends Sort {
    @Override
    public void sort() {
        for(int i = array.length - 1; i > 0; i--){
            int maxIndex = 0;
            for(int j = 1; j <= i; j++){
                if (cmp(maxIndex, j) <= 0) {
                    maxIndex = j;
                }
            }
            swap(i, maxIndex);
        }
    }
}
